﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<PollInputModels>" %>

<%@ Import Namespace="SDT.Lib.Helpers" %>
<%@ Import Namespace="SDT.Lib.Paging" %>
<%@ Import Namespace="SDT.Admin.ViewModels" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Thêm mới Polls
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <%if (ViewData["MessageInfo"] == null)
      { %>
    <% using (Html.BeginForm("Create", "Polls", FormMethod.Post, new
       {
           id = "adminForm",
           enctype = "multipart/form-data"
       }))
       {%>
    <%= Html.ValidationSummary(true)%>
    <table class="admintable" width="100%">
        <tbody>
            <tr>
                <td class="key">
                    Chọn Menu (<font color="red">*</font>)
                </td>
                <td>
                    <%=Html.ListBoxFor(m => m.MenuID, new SelectList(Model.ListMenus, "ID", "Name"), new
{
    @class = "required",
    @multiple = "multiple",
    @size = "10"
})%>
                </td>
            </tr>
            <tr>
                <td class="key">
                    Nội dung (<font color="red">*</font>)
                </td>
                <td>
                    <%=Html.TextAreaFor(m=>m.Poll.PollContent, new { @class="required", @rows="4",@cols="80" })%>
                </td>
            </tr>
            <tr>
                <td class="key">
                    Ngày bắt đầu (<font color="red">*</font>)
                </td>
                <td>
                    <%=Html.TextBoxFor(m => m.Poll.PollFrom, new { @class = "required datepicker" })%>
                </td>
            </tr>
            <tr>
                <td class="key">
                    Ngày kết thúc (<font color="red">*</font>)
                </td>
                <td>
                    <%=Html.TextBoxFor(m => m.Poll.PollTo, new { @class = "required datepicker" })%>
                </td>
            </tr>
            <tr>
                <td class="key">
                    Trạng thái hiển thị
                </td>
                <td>
                    <%= Html.RadioButtonFor(m=>m.Poll.PubYN, true, new { @checked = "checked" })%>
                    Đăng tin
                    <%= Html.RadioButtonFor(m=>m.Poll.PubYN, true)%>
                    Không đăng
                </td>
            </tr>
            <tr>
                <td class="key">
                    Trường hợp trả lời
                </td>
                <td>
                    <table id="frmFile" width="100%" class="adminlist">
                        <tr>
                            <th>
                                Trường hợp trả lời:
                            </th>
                        </tr>
                        <tr>
                            <td>
                                <input id="PollCase1" style="width: 350px;" name="PollCase1" type="text"/>
                                &nbsp;<input id="btnAddFile" type="button" value="Thêm" onclick="AddFile();" />
                            </td>
                        </tr>
                    </table>

                    <script type="text/javascript">
                        var fileIndex = 1;
                        function AddFile() {
                            fileIndex++;
                            var tag = "<td><input id='PollCase" + fileIndex.toString() + "' name='PollCase" + fileIndex.toString() + "' type=\"text\"  style='width: 350px;'\" /></td>";
                            var row = "<tr>" + tag + "</tr>";
                            $("#frmFile").append(row);
                            $("#PollCaseIndex").val(fileIndex);
                        };
                    </script>

                </td>
            </tr>
            <tr>
                <td colspan="2" align="center">
                    <input type="hidden" name="PollCaseIndex" id="PollCaseIndex" value="<%= Model.PollCaseIndex %>" />
                    <input type="hidden" name="Poll.nAnswers" id="Poll.nAnswers" value="0" />
                    <input type="submit" id="btnSave" value="Thêm mới" />
                </td>
            </tr>
        </tbody>
    </table>
    <%}
      } %>

    <script type="text/javascript">
        $(document).ready(function() {
            $("#adminForm").validate();

            $(".datepicker").datepicker({
                dateFormat: "dd/mm/yy",
                changeMonth: true,
                showOn: "button",
                buttonImage: "/Images/calendar.gif",
                buttonImageOnly: true,
                changeYear: true
            });
        });
    </script>

</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="Toolbar" runat="server">
    <%= Html.Toolbar("Quay lại", "/Polls", "back")%>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="Header" runat="server">
    Thêm mới Polls
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="Message" runat="server">
    <%=ViewData["MessageInfo"]!=null? "<p class='perror'>"+Html.Encode(ViewData["MessageInfo"])+"</p>":string.Empty%>
</asp:Content>
